#include<iostream> 
#include<vector>
using namespace std;

class Solution {
public:
    int removeDuplicates(vector<int>& nums)
    {
        if(nums.size() <= 1){
            return nums.size();
        }
        int i = 0, j = 1;
        while(j < nums.size()){
            if(nums[i] != nums[j]){
                i++;
            }
            nums[i] = nums[j];
            j++;
        }
        return i + 1;
    }
};

/**
 * @brief 2022.7.18
 * 双指针
 * 
 */
